import React, { useRef } from 'react'
import Child from './child'

function FuncContainer() {
    const childRef = useRef();
    const getRef = () => {
        const { increment } = childRef.current;
        increment();
    };
    const refReset = () => {
        const { setNum } = childRef.current;
        setNum(0)
    };
    return (
        <div className='wrapper'>
            <Child ref={childRef} />
            <button onClick={getRef} className='ml-3 btn btn-danger'>父组件直接调取子组件方法</button>
            <button onClick={refReset} className='ml-3 btn btn-warning'>父组件直接更改子组件状态</button>
        </div>
    )
}

export default FuncContainer